# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

_realname=neon
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.31.2
pkgrel=1
pkgdesc="HTTP and WebDAV client library with a C interface (mingw-w64)"
arch=('any')
url="https://notroj.github.io/neon/"
license=('GPL' 'LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-expat"
         "${MINGW_PACKAGE_PREFIX}-openssl"
         "${MINGW_PACKAGE_PREFIX}-ca-certificates")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('libtool' 'staticlibs') # FS#16067
source=(https://notroj.github.io/neon/${_realname}-${pkgver}.tar.gz
        neon-0.30.2-mingw-w64.patch)
sha256sums=('cf1ee3ac27a215814a9c80803fcee4f0ede8466ebead40267a9bd115e16a8678'
            'a1e19dcd755784168542930a0e351506eb1bfc5d941904aa970f81b5b489a95d')
validpgpkeys=('190555472DCC589BEF01609C608A86DF9833CC49') #Joe Orton <joe@manyfish.uk>

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/neon-0.30.2-mingw-w64.patch

  ./autogen.sh
  #autoreconf -fi
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --with-expat \
    --enable-shared \
    --disable-static \
    --with-ssl=openssl \
    --with-ca-bundle=${MINGW_PREFIX}/ssl/certs/ca-bundle.crt
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
